home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*------------------------*
- * CPPLTC2.C *
- * Integrator *
- * Manager & Applications *
- *------------------------*/
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <alloc.h>
- # include <time.h>
- # include <conio.h>
- # include <fcntl.h>
- # include <sys\stat.h>
-
- /* Global Variables */
- extern int j,bm,colour3,pfdiv;
- extern unsigned int jouract,monthact,yearact;
- extern long tbeginning,tend,tdiff,depdiv;
- extern unsigned long nbbytes;
- extern unsigned char c1,c2,nc2[],trashcan[],work[];
-
- /*---------*
- * GET KEY *
- *---------*/
- int get_key()
- {
- /* We return a code which depends on the pressed key */
- if((c1==48)||(c1==133)) return(0); /* 0/à */
- if((c1==49)||(c1==38)) return(1); /* 1/& */
- if((c1==50)||(c1==130)) return(2); /* 2/é */
- if((c1==51)||(c1==34)) return(3); /* 3/" */
- if((c1==52)||(c1==39)) return(4); /* 4/' */
- if((c1==53)||(c1==40)) return(5); /* 5/( */
- if((c1==54)||(c1==45)) return(6); /* 6/- */
- if((c1==55)||(c1==138)) return(7); /* 7/è */
- if((c1==56)||(c1==95)) return(8); /* 8/_ */
- if((c1==57)||(c1==135)) return(9); /* 9/ç */
- if((c1==65)||(c1==97)) return(10); /* A/a */
- if((c1==66)||(c1==98)) return(11); /* B/b */
- if((c1==67)||(c1==99)) return(12); /* C/c */
- if((c1==68)||(c1==100)) return(13); /* D/d */
- if((c1==69)||(c1==101)) return(14); /* E/e */
- if((c1==70)||(c1==102)) return(15); /* F/f */
- if((c1==71)||(c1==103)) return(16); /* G/g */
- if((c1==72)||(c1==104)) return(17); /* H/h */
- if((c1==73)||(c1==105)) return(18); /* I/i */
- if((c1==74)||(c1==106)) return(19); /* J/j */
- if((c1==75)||(c1==107)) return(20); /* K/k */
- if((c1==76)||(c1==108)) return(21); /* L/l */
- if((c1==77)||(c1==109)) return(22); /* M/m */
- if((c1==78)||(c1==110)) return(23); /* N/n */
- if((c1==79)||(c1==111)) return(24); /* O/o */
- if((c1==80)||(c1==112)) return(25); /* P/p */
- if((c1==81)||(c1==113)) return(26); /* Q/q */
- if((c1==82)||(c1==114)) return(27); /* R/r */
- if((c1==83)||(c1==115)) return(28); /* S/s */
- if((c1==84)||(c1==116)) return(29); /* T/t */
- if((c1==85)||(c1==117)) return(30); /* U/u */
- if((c1==86)||(c1==118)) return(31); /* V/v */
- if((c1==87)||(c1==119)) return(32); /* W/w */
- if((c1==88)||(c1==120)) return(33); /* X/x */
- if((c1==89)||(c1==121)) return(34); /* Y/y */
- if((c1==90)||(c1==122)) return(35); /* Z/z */
- if(c1==27) return(-1); /* <Esc> */
- if(c1==13) return(40); /* <Enter> */
- if(c1==32) return(41); /* <Space> */
- if(c1==8) return(42); /* <Backspace> */
- /* In all the other cases we return 99 = no choice */
- return(99);
- }
- /*-----------------*
- * GET SPECIAL KEY *
- *-----------------*/
- int get_special_key()
- {
- if(c2==59) return(59); /* <F1> = Help */
- if(c2==60) return(60); /* <F2> = */
- if(c2==61) return(61); /* <F3> = */
- if(c2==62) return(62); /* <F4> = */
- if(c2==63) return(63); /* <F5> = */
- if(c2==64) return(64); /* <F6> = */
- if(c2==72) return(72); /* <Up arrow> */
- if(c2==75) return(75); /* <Left arrow> */
- if(c2==77) return(77); /* <Right arrow> */
- if(c2==80) return(80); /* <Down arrow> */
- if(c2==71) return(71); /* <Home> */
- if(c2==73) return(73); /* <PgUp> */
- if(c2==79) return(79); /* <End> */
- if(c2==81) return(81); /* <PgDn> */
- if(c2==82) return(82); /* <Inser> */
- if(c2==83) return(83); /* <Suppr> */
- if(c2==121) return(221); /* Alt + 2 */
- if(c2==122) return(222); /* Alt + 3 */
- if(c2==123) return(223); /* Alt + 4 */
- if(c2==124) return(224); /* Alt + 5 */
- if(c2==125) return(225); /* Alt + 6 */
- if(c2==126) return(226); /* Alt + 7 */
- if(c2==127) return(227); /* Alt + 8 */
- if(c2==35) return(135); /* Alt + H */
- if(c2==46) return(146); /* Alt + C */
- if(c2==33) return(133); /* Alt + F */
- return(99); /* Other case : no choice */
- }
- /*----------------*
- * WAIT FOR A KEY *
- *----------------*/
- int wait_for_a_key()
- {
- /* We wait for a keyboard key or a mouse button to be pressed */
- /* We foresee a high number of standard return values to use this */
- /* as often as possible */
- while(1){
- if(kbhit()){
- /* we pressed a keyboard key */
- c1=getch();
- if(c1>0){
- /* One byte key */
- j=get_key(); return(j);
- }
- if(c1==0){
-
- /* 2-bytes coded key, we get the second */
- c2=getch(); j=get_special_key();
- return(j);
- }
- }
- /* Else did we press a mouse button ?????? */
- get_mouse_state();
- if(bm==1) return(100);
- }
- }
- /*------------------------*
- * SET UP PRINTER MESSAGE *
- *------------------------*/
- int set_up_printer_message()
- {
- /* We save the window */
-
- /* TO BE MODIFIED */
-
- /* outtextxy(437,300,"Please check the ");
- outtextxy(437,315,"printer : Switched on ");
- outtextxy(437,330,"and on line ");
- outtextxy(437,345,"<Esc> = Abord print ");
- outtextxy(437,360,"When you are ready ");
- outtextxy(437,375,"press any key or click ");
- sound2(); c1=0x20; */
- j=wait_for_a_key();
- if(j==-1) return(0);
- else return(1);
- }
- /*--------------------*
- * CHECK THE VALIDITY *
- *--------------------*/
- int check_the_validity()
- {
- /* Disabled with month>12 */
- get_the_system_date();
- if(yearact>1994) return(0);
- if(monthact>12) return(0);
- return(1);
- }
- /*----------------------*
- * GET DATE TEXT FORMAT *
- *----------------------*/
- void get_date_text_format()
- {
- /* We format the system date in xx/xx/xx */
- get_the_system_date(); right_justify(jouract,2);
- strcpy(trashcan,nc2); strcat(trashcan,"/");
- right_justify(monthact,2); strcat(trashcan,nc2);
- strcat(trashcan,"/"); right_justify(yearact,2);
- strcat(trashcan,nc2);
- }
- /*--------------*
- * GET DURATION *
- *--------------*/
- void get_duration()
- {
- time_t t;
- t=time(NULL); tbeginning=t;
- wait_for_a_key();
- t=time(NULL); tend=t;
- tdiff=tend-tbeginning;
- }
- /*---------------------*
- * DISPLAY FREE MEMORY *
- *---------------------*/
- void display_free_memory()
- {
- save_screen2(54,13); textattr(colour3);
- hide_the_mouse();
- gotoxy(55,15); cputs(" ┌─────────────────────┐ ");
- gotoxy(55,16); cputs(" │ Available Memory : │ ");
- gotoxy(55,17); cputs(" │ │ ");
- gotoxy(55,18); cputs(" │ │ ");
- gotoxy(55,19); cputs(" │ Press any key │ ");
- gotoxy(55,20); cputs(" │ or click │ ");
- gotoxy(55,21); cputs(" └─────────────────────┘ ");
- nbbytes=coreleft(); gotoxy(60,17);
- printf("%ld bytes",nbbytes); show_the_mouse();
- wait_for_a_key();
- restore_screen2(54,13);
- }
- /*-------------------------*
- * OPEN CLEAN DIVERSE FILE *
- *-------------------------*/
- int open_clean_diverse_file()
- {
- /* We check that the file is closed before opening it */
- if(pfdiv>0) close(pfdiv);
- strcpy(trashcan,work); strcat(trashcan,"\\DIVERS.FIC");
- pfdiv=open(trashcan,O_RDWR|O_TRUNC | O_BINARY, S_IREAD|S_IWRITE);
- if(pfdiv==-1){
- warning(" Cannot open"," the divers file"," for an update","","");
- return(0);
- }
- depdiv=lseek(pfdiv,0L,SEEK_SET); return(1);
- }
- /*-------------------*
- * OPEN DIVERSE FILE *
- *-------------------*/
- int open_diverse_file()
- {
- /* We check whether the file is closed before opening it */
- if(pfdiv>0) close(pfdiv);
- strcpy(trashcan,work); strcat(trashcan,"\\DIVERS.FIC");
- pfdiv=open(trashcan,O_RDWR | O_BINARY, S_IREAD|S_IWRITE);
- if(pfdiv==-1){
- warning(" Cannot open"," the divers file"," for an update","","");
- return(0);
- }
- depdiv=lseek(pfdiv,0L,SEEK_SET); return(1);
- }
- /* End of the Module */ /*-----------------------*/
-